package com.winchain.chainbill.bill.biz.discount.rx;

import com.shell.framework.command.ChainBase;
import com.shell.framework.command.CommandContext;
import com.shell.framework.rx.OnErrorNotImplementedSubscriber;
import com.winchain.chainbill.bill.base.po.CbDct;
import com.winchain.chainbill.bill.biz.Bill;
import com.winchain.chainbill.bill.biz.BillEvent;
import com.winchain.chainbill.bill.biz.discount.cmd.BillSerFeeDebitSponsorCmd;
import com.winchain.chainbill.bill.biz.discount.cmd.BillSerFeeSponsorCmd;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class BillSeeFeeContractSponsorSubscriber extends OnErrorNotImplementedSubscriber<BillEvent<CbDct>> {
	@Autowired
	private BillSerFeeSponsorCmd billSerFeeSponsorCmd;
	@Autowired
	private BillSerFeeDebitSponsorCmd billSerFeeDebitSponsorCmd;

	public void onApplicationEvent(BillEvent<CbDct> t) {
		Bill<CbDct> bill = t.getBill();
		CommandContext<Bill<CbDct>> context = new CommandContext();
		context.setSource(bill);
		ChainBase<Bill<CbDct>> crb = new ChainBase();
		crb.add(this.billSerFeeSponsorCmd);
		crb.add(this.billSerFeeDebitSponsorCmd);
		crb.execute(context);
	}
}
